package com.example.administrator.fragarmentdemotest_a.fragarment_demo.frag;

import android.graphics.Color;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.administrator.fragarmentdemotest_a.R;
import com.example.administrator.fragarmentdemotest_a.fragarment_demo.Bean.FriendsGroupBean;
import com.example.administrator.fragarmentdemotest_a.fragarment_demo.adapter.RvMsgAdapter;
import com.example.administrator.fragarmentdemotest_a.utils.JsonUtils;
import com.example.administrator.fragarmentdemotest_a.utils.app.BaseFragment;
import com.google.gson.reflect.TypeToken;

import io.realm.RealmList;

import static com.example.administrator.fragarmentdemotest_a.R.drawable.dkgray_bg_shape;

public class ContactFriendFragment extends BaseFragment {
    private String myJson = "[{\"id\":1,\"name\":\"好友\",\"friends\":[{\"id\":1,\"name\":\"红猪\",\"headUrl\":\"https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u\\u003d3198678185,878755003\\u0026fm\\u003d27\\u0026gp\\u003d0.jpg\"},{\"id\":2,\"name\":\"黑帽子\",\"headUrl\":\"https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u\\u003d1934952861,3453579486\\u0026fm\\u003d27\\u0026gp\\u003d0.jpg\"},{\"id\":3,\"name\":\"Ara\",\"headUrl\":\"https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u\\u003d3303741086,3211617265\\u0026fm\\u003d27\\u0026gp\\u003d0.jpg\"},{\"id\":4,\"name\":\"Bri\",\"headUrl\":\"https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u\\u003d4233882545,270382672\\u0026fm\\u003d27\\u0026gp\\u003d0.jpg\"}]},{\"id\":2,\"name\":\"家人\",\"friends\":[{\"id\":5,\"name\":\"苹果\",\"headUrl\":\"https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u\\u003d2659519208,2040552462\\u0026fm\\u003d27\\u0026gp\\u003d0.jpg\"},{\"id\":6,\"name\":\"Smoke\",\"headUrl\":\"https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u\\u003d3063085903,3230502727\\u0026fm\\u003d27\\u0026gp\\u003d0.jpg\"},{\"id\":7,\"name\":\"BigDog\",\"headUrl\":\"https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u\\u003d2370424667,3031767846\\u0026fm\\u003d27\\u0026gp\\u003d0.jpg\"}]},{\"id\":3,\"name\":\"XX公司\",\"friends\":[{\"id\":8,\"name\":\"小蜘蛛\",\"headUrl\":\"https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u\\u003d1053771801,4239224829\\u0026fm\\u003d27\\u0026gp\\u003d0.jpg\"},{\"id\":9,\"name\":\"Ali\",\"headUrl\":\"https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u\\u003d3266183129,26862261\\u0026fm\\u003d27\\u0026gp\\u003d0.jpg\"},{\"id\":10,\"name\":\"Logan\",\"headUrl\":\"https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u\\u003d2503440006,744810055\\u0026fm\\u003d27\\u0026gp\\u003d0.jpg\"},{\"id\":11,\"name\":\"Es\",\"headUrl\":\"http://img4.imgtn.bdimg.com/it/u\\u003d2838532421,4231779873\\u0026fm\\u003d27\\u0026gp\\u003d0.jpg\"},{\"id\":12,\"name\":\"SmallCat\",\"headUrl\":\"http://img0.imgtn.bdimg.com/it/u\\u003d2661993305,1199724439\\u0026fm\\u003d27\\u0026gp\\u003d0.jpg\"}]},{\"id\":4,\"name\":\"客户\",\"friends\":[{\"id\":13,\"name\":\"Mask\",\"headUrl\":\"http://img5.imgtn.bdimg.com/it/u\\u003d1606972337,3987749266\\u0026fm\\u003d200\\u0026gp\\u003d0.jpg\"},{\"id\":14,\"name\":\"SmallCar\",\"headUrl\":\"http://img1.imgtn.bdimg.com/it/u\\u003d2623703544,3858420575\\u0026fm\\u003d27\\u0026gp\\u003d0.jpg\"}]},{\"id\":5,\"name\":\"新分组\",\"friends\":[]}]";
    private RecyclerView rv_msg;
    public static final int DKGRAY = 0xFF444444;
    @Override
    protected View initView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container) {
        View view = inflater.inflate(R.layout.frag_msg, container, false);
        rv_msg = view.findViewById(R.id.rv_msg);
        container.setBackgroundResource(R.drawable.dkgray_bg_shape);
        return view;
    }

    @Override
    protected void initData() {
        RealmList<FriendsGroupBean> listAll = JsonUtils.toBean(myJson, new TypeToken<RealmList<FriendsGroupBean>>() {
        }.getType());
        RvMsgAdapter adapter = new RvMsgAdapter(listAll);
        rv_msg.setLayoutManager(new LinearLayoutManager(act));
        rv_msg.setAdapter(adapter);
    }

    @Override
    protected void initListener() {

    }
}
